<template>
    <div class="section-wrap" style="height:100%">

        <!-- 头部 -->
         <div class="headerBox">
        <div class="header" v-if="params.status==1">
            <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>待开展量化考核
        </div>
        <div class="header" v-if="params.status==2">
            <x-icon type="ios-arrow-left" size="" class="icon-white" @click="goBack"></x-icon>审核量化考核记录
        </div>
        </div>
        <div class="form-section" style="margin-top: 40px;">
            <div class="info_div2">
                <div class="form-item">
                    <div><span>考核计划数量：{{totalCount}}次</span></div>
                </div>
            </div>
            <div class="project_div">
                <ul class="project_list">
                     <li v-for='(item,index) in accpentlist' :key="index" @click="auditRecord(item)">
                       <div class="lf">
                        <span style="font-weight: bold;">{{item.beDepartName}}</span>
                        <span class="statues" v-if="item.rocordStatus==0" style="color:red;">【未提交】</span>
                        <span class="statues" v-else-if="item.rocordStatus!=3&&item.commitDivision!=item.totalDivision"> 【{{item.commitDivision}}/{{item.totalDivision}}】</span>
                        <span class="statues" v-else-if="item.rocordStatus!=3&&item.commitDivision==item.totalDivision" style="color:red;">【{{item.commitDivision}}/{{item.totalDivision}}】</span>
                        <span class="statues" style="color:green;" v-else >【已完成】</span><p class="classifyOneName"> {{item.checkNo}}</p>
                        <p class="classifyOneName">{{item.classifyOneName==null?' ':item.classifyOneName}}</p>
                      </div>
                      <div class="rf">
                        <p class="project_time">{{item.checkDate.substring(0, 10)}}</p>
                      </div>
                      <x-icon type="ios-arrow-right" size="22" class="icon-right"></x-icon>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>
<script>
import VueBetterScroll from "vue2-better-scroll";
export default {
  data() {
    return {
      /*下拉刷新*/
      resultlist: [],
      scrollbarObj: { fade: true },
      pullDownRefreshObj: false,
      pullUpLoadObj: {
        threshold: 0,
        txt: {
          more: "加载更多",
          noMore: "没有更多数据了"
        }
      },
      startY: 0,
      scrollToX: 0,
      scrollToY: 0,
      scrollToTime: 700,
      isDisabled: true, // 是否禁止输入
      detailData: {
        ResolveStartTime: "2019-07-01",
        ResolveEndTime: "2019-08-29",
        DeptName1: "全部",
        DeptName2: "北京华电豆粒有限公司"
      },
      accpentlist: [],
      totalCount: "",
      params: {
        id: [],
        planId: "",
        startDate: "",
        endDate: "",
        checkDepartId: "",
        status: 1,
        skipCount: 0,
        maxResultCount: 10
      }
    };
  },
  components: { VueBetterScroll },
  created() {
    if(this.$route.query.status){
      this.params.status=this.$route.query.status;
    }
    
  },
  mounted(){
        let that = this;
        this.$bridge.registerHandler("setToken", function(data) {
                         that.$store.state.Authorization =
          "Bearer " + data;
          if(that.$route.query.status){
            that.params.status=that.$route.query.status;
          }
         
            //这里data ioS返回的是token值(字符串)
        });

        this.connectWebViewJavascriptBridge(function(bridge) {
            bridge.registerHandler("setToken", function(data) {
                             that.$store.state.Authorization =
          "Bearer " + data;
          if(that.$route.query.status){
            that.params.status=that.$route.query.status;
          }
                  //这里data android返回的是token值(字符串)

            });
        });
        this.getData();
    },
  methods: {
    connectWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge);
            } else {
                document.addEventListener(
                "WebViewJavascriptBridgeReady",
                function() {
                    callback(WebViewJavascriptBridge);
                },
                false
                );
            }
        },
    getData() {
      this.$axiosAjax.GetPageListAssessment(this.params).then(res => {
        this.totalCount = res.data.result.totalCount;
        let relist = res.data.result.items;
        if (this.params.skipCount==0) {
          this.accpentlist = []
        }
        this.accpentlist = this.accpentlist.concat(relist);
        let totalAllCount = res.data.result.totalCount;
        let resultCount = this.accpentlist.length;
        if (parseInt(resultCount) < parseInt(totalAllCount)) {
          this.$refs["scrollqq"].forceUpdate(true);
        } else {
          this.$refs["scrollqq"].forceUpdate(false);
        }
      });
    }, //需要执行的量化考核
    goBack() {
      this.$bridge.callHandler({
              type: 'closePage',
              data: {}
            });
    },
    onPullingUp() {
      let limitcount = this.accpentlist.length;
      this.params.skipCount = limitcount;
      this.getData();
    },
    onPullingDown() {
      this.getData();
    },
    auditRecord(item){
        if(item.isCheck){
            this.$router.push({path:'/checkRecord',query:{id:item.id}});
        }else{
            if(item.isAudit){
                this.$router.push({path:'/auditRecord',query:{id:item.id}});
            }else{
                this.$router.push({path:'/recordDetails',query:{id:item.id}});
            }
        }
    }
  }
};
</script>
<style lang="less" scoped>
.lf{
  float: left;
  height: 100%;
  width: 70%;


  line-height: 25px;
}
.rf{
  float:right;
   height: 100%;
  width: 30%;
  line-height: 50px;
}
  .form-i
.info_div2 {
  border-top: none;
}
.project_div {
  .project_list {
    padding-left: 20px;
    li {
      border-bottom: 1px solid #efeff4;
      height: 95px;
      position: relative;
      padding-top: 18px;
      padding-right: 22px;
      h4 {
        width: calc(100% - 40px);
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        font-size: 16px;
        margin-bottom: 8px;
        font-weight: bold;
      }
      p {
        span {
          font-size: 14px;
          color: #666;
        }
        span:first-child {
          margin-right: 40px;
        }
      }
      .project_status {
        margin-top: 14px;
        strong {
          font-size: 12px;
        }
        strong.project_status1 {
          color: #ff7333;
        }
        strong.project_status2 {
          color: #469b7a;
        }
      }
      .vux-x-icon {
        fill: #999;
        right: 20px;
        top: 50%;
        margin-top: -11px;
        position: absolute;
      }
      .classifyOneName{
        color: #666;
        font-size: 14px;
      }
    }
  }
}
</style>
